<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var a = 10;
    var foo = function (){
        alert('b'+a);
        a = 20;
    }
    alert('a'+a);
    foo();
    alert('c'+a);



    function foo2(){
        alert('2a'+b);

        var b = 10;
    }
    foo2();
    alert('2b'+b);




</script>
</body>
</html>